package com.tiantianyuegou.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tiantianyuegou.R;
import com.tiantianyuegou.util.SelfUtils;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/1/27.
 *
 */
public class ProcessAdapter extends BaseAdapter{
    private Context context;
    private LayoutInflater inflater;
    private List<Map<String,String>> list;

    private String[] processName={"订单编号：","支付时间：","下单时间：","发货时间：","支付时间："};
    private String[] process={"toNumber","toPayTime","toAddtime","toTodTime","toReceiveTime"};

    public ProcessAdapter(Context context){
        this.context=context;
        inflater=LayoutInflater.from(context);
    }

    public void Data(List<Map<String,String>> list){
        this.list=list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        HolderView holderView=null;
        if (view==null){
            view=inflater.inflate(R.layout.item_list_process,null);
            holderView=new HolderView();
            holderView.text_process_name=(TextView)view.findViewById(R.id.text_process_name);
            holderView.text_process_date=(TextView)view.findViewById(R.id.text_process_date);
            view.setTag(holderView);
        }else{
            holderView=(HolderView)view.getTag();
        }


        for (int s=0;s<list.size();s++) {
            Map<String,String> map=list.get(s);
            String str=map.get("same");
            if (!TextUtils.isEmpty(str) || null != str) {
                if (0 == s) {
                    holderView.text_process_name.setText(processName[s]);
                    holderView.text_process_date.setText(str);
                } else {
                    holderView.text_process_name.setText(processName[s]);
                    holderView.text_process_date.setText(new SelfUtils().getDate(str));
                }

            }
        }
        return view;
    }

    class HolderView{
        TextView text_process_name,text_process_date;
    }
}
